home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
optivc32
/
cmath.txt
< prev
next >
Wrap
Text File
|
1999-03-06
|
40KB
|
871 lines
CCCCCCC MM MM A TTTTTTTTTT HH HH
CC MMM MMM AAA TT HH HH
CCC MMMM MMMM AA AA TT HH HH
CCC MM MM MM MM AA AA TT HHHHHHHHHH
CCC MM MM MM MM AAAAAAAAA TT HH HH
CC MM MMM MM AA AA TT HH HH
CCCCCCC MM M MM AA AA TT HH HH
CMATH 1.5
Dr. Martin Sander Software Development
Sertürnerstr. 11
D-37085 Göttingen
Germany
e-mail: MartinSander@Bigfoot.com
http://www.optivec.com
For the commercial version, please order by e-mail or through our web-site!
See chapter 1.3 for details.
*****************************************************************************
!! This is an ASCII text file! It is best viewed with a simple !!
!! DOS editor. !!
!! If you load this file into a word processor under Windows, you !!
!! must use the filter "DOS text". !!
!! Alternatively, you may use FCONVERT (shipped with Borland C++) to !!
!! convert from ASCII (OEM) into the ANSI character set. !!
!! preferably use the lettertype CourierNew 10 pt. !!
**************************************
German-speaking users:
Um die Kosten für das Herunterladen der Shareware-Version
über das Internet für alle so gering wie möglich zu halten,
enthält diese nur die englische Dokumentation. Sie finden
die deutsche Beschreibung separat unter
http://www.gwdg.de/~msander/Download/BC/CMDOCD.ZIP
**************************************
OptiCode (TM) and OptiVec (TM) are trademarks of Dr. Martin Sander
Software Dev. Other brand and product names mentioned in this handbook
for identification purposes are trademarks or registered trademarks of
their respective holders.
****************************************************************************
* *
******* Contents *******
* *
****************************************************************************
1. Introduction
1.1 What is CMATH ?
1.2 Licence Terms
1.3 Registered Versions
2. Getting Started
2.1 Installation
2.2 De-Installation
3. Overview over the Functions of CMATH
3.1 Initialization of Complex Numbers
3.2 Data-Type Interconversions
3.3 Basic Complex Operations
3.4 Arithmetic Operations
3.5 Mathematical Functions
4. Error Handling
4.1 General Error Handling of Complex Functions
4.2 Advanced Error Handling: Writing Messages into a File
5. Syntax Reference
5.1 C++ Version
5.2 Plain-C Version
****************************************************************************
* *
******* 1. Introduction *******
* *
*****************************************************************************
1.1 What is CMATH ?
-------------------
CMATH is a comprehensive library for complex-number arithmetis and
mathematics. It is primarily intended as a high-quality replacement for
the C++ complex class libraries presently available. In addition,
all functions may be called from C, without the necessity to use C++.
Superior speed, accuracy and safety are achieved through the
implementation in Assembly language (as opposed to the compiled or
inline C++ code of the complex class libraries).
Only for the most simple tasks, alternative inline C++ functions are used.
The implementation was guided by the following rules:
1. Without any compromise, top priority is always given to the mathema-
tically correct result, with the accuracy demanded for the respective
data type. Especially for complex functions, this necessitates a
very thorough treatment of many different situations. To this end,
the various cases have to be distinguished with pedantic care.
2. Mathematical functions must be "safe" under all circumstances.
They may for no reason simply crash, but have to perform a decent
error treatment. This is true even - and perhaps especially - for
seemingly nonsense arguments, with the single exception of the
non-numbers INF and NAN, which occur themselves only as a result
of serious errors in other functions.
3. By all possible means, greatest execution speed must be attained.
(After all, you did not buy your fast computer for nothing!)
4. The program code has to be as compact as possible. However, in case
of conflicts, faster execution speed is always given priority
over smaller code size.
Having a look into the complex class libraries shipped with popular compilers,
you will immediately discover the differences between our approach and theirs.
Often the mathematical functions are implemented by simply writing down the
textbook formula. This yields relatively compact source code. But, due to
round-off error of intermediate results, the final results returned by these
functions are sometimes very inaccurate or even completely wrong. Moreover,
they may lead to unhandled floating-point errors (this means: program crash!).
Unnecessary to mention that the code thus generated is rather slow.
For programmers who prefer classis C-style functions over C++, CMATH
provides all complex-number operations and functions also for the language C.
This is accomplished through an additional set of alternative declarations
of the complex types as structs in place of classes.
CMATH versions for Pascal and Delphi are also available. As far as possible,
all functions have the same names in the Pascal/Delphi version as in the
C version.
The C++ classes and the C structs are binary compatible with each other.
This point may become important for large projects with mixed C and C++
modules.
Existing Borland C++ code which uses the complex class library contained in
<complex.h> can be left unchanged, because the CMATH functions and data
types are also binary compatible with those of <complex.h>.
Here is a detailed description of how to switch from the complex classes of
Borland C++ to the new implementation given by CMATH:
* In C++ modules, replace the statement
#include <complex.h>
by the statement
#include <newcplx.h>
Then, the following three complex classes are defined:
class complex<float>, class complex<double>,
and class complex<extended>.
The data types fComplex, dComplex, and eComplex are defined as
synonyms for these classes.
In order to avoid the letter "L" (which is already over-used by
"long int" and "unsigned long" in the language C), the type
"extended" is used here as a synonym for "long double".
Consequently, the complex data type consisting of long doubles
is named "eComplex".
Thereby, the way is held open for a future inclusion of whole-
number complex types into CMATH. Then,"liComplex" and "ulComplex"
will denote the complex types consisting of "long int" or
"unsigned long" parts, respectively.
* If you prefer to have the "classic" class complex of older releases
of Borland C++, you have to declare
#define CMATH_CLASSIC_COMPLEX
before (!) including <newcplx.h>.
In this case, only the class complex will be defined and gets the synonym
dComplex. Here you will have no access to the complex-number functions of
float and of